package com.hopu.dy.mapper;


import com.hopu.dy.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    /**
     * 根据邮箱查用户
     * @param email
     * @return
     */
    @Select("select * from t_user where email=#{email}")
    User selectByEmail(String email);

    /**
     * 新增用户
     * @param user
     * @return
     */
    @Insert("insert into t_user(email,password,nickname,avatar,gender,age,register_time,register_ip,login_time)values (#{email},#{password},#{nickname},#{avatar},#{gender},#{age},#{registerTime},#{registerIp},#{loginTime})")
    int insert(User user);

    /**
     * 修改信息
     * @param user
     */
    @Update("update t_user set email=#{email},nickname=#{nickname},avatar=#{avatar},gender=#{gender},register_ip=#{registerIp},age=#{age} where id=#{id}")
    void update(User user);
}
